home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #1 / Amiga Plus 1995 #1.iso / fish-disketten / fish_691-700 / d695 / icalc / s / icalc.init next >
Text File  |  1994-12-13  |  2KB  |  55 lines

  1. # Standard startup-file for icalc.
  2. # Updated for version 2.0. Also, you may want to include other scripts
  3. # (such as gamma.ic) by read command.
  4. #
  5. # MWS, February 1992.
  6.  
  7. silent        # switch off confirmation of definitions
  8.  
  9. # function informing you how long icalc session has been running in minutes.
  10. _sessionstart = time(0)
  11. func session() = time(_sessionstart) / 60
  12.  
  13. # simple stopwatch functions
  14. func start() = (_start = time(0))
  15. func stop() = time(_start)
  16.  
  17. # a few simple time-savers
  18. func deg(z) = DEG*z        # convert radians to degrees
  19. func rad(z) = z/DEG        # and degrees to radians
  20. func log(z) = ln(z)/LOG10    # base-10 logarithm
  21. func lg(z) = ln(z)/LOG2        # base-2 logarithm
  22. func logn(z,n) = ln(z)/ln(n)    # base-n logarithm
  23.  
  24. # inverse hyperbolic trig functions
  25. func asinh(z) = -i*asin(i*z)
  26. func acosh(z) = -i*acos(z)
  27. func atanh(z) = i*atan(-i*z)
  28.  
  29. # combinatorics - could be replaced with defs in gamma.ic
  30. func fact(n) = Prod(_n=1,n,_n)
  31. func perm(n,r) = Prod(_n=n-r+1,n,_n)
  32. func comb(n,r) = perm(n,r)/fact(r)
  33.  
  34. # miscellaneous
  35.  
  36. # fractional part of a number
  37. func frac(z) = Re(z - floor(z))
  38.  
  39. # round real & imag parts
  40. func round(z,places) = int(z*10^places)/10^places
  41.  
  42. # create complex number from modulus and argument
  43. func polar(r,theta) = r*exp(i*theta)
  44.  
  45. # create complex number from real and imaginary parts
  46. func complex(real,imag) = real + i*imag
  47.  
  48. # convert decimal hours to hours, mins, seconds
  49. func hms(h) = { print(floor(h)); print(floor(_t = frac(h)*60)); frac(_t)*60; }
  50.  
  51. # convert hours, mins, seconds to decimal hours
  52. func hours(h,m,s) = h+m/60+s/3600
  53.  
  54. verbose        # restore display of results, messages
  55.